<?php

namespace app\index\controller;

use think\Controller;

class News extends Border
{
    public function index()
    {
        $apikey = 'ff59d068d04d4b023c3b782ebbec46d0';
        $url = 'http://v.juhe.cn/toutiao/index?type=top&key=' . $apikey;
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        // 将curl_exec()获取的信息以字符串返回，而不是直接输出。
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        // 设定为 不验证SSL证书和HOST
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

        $data = curl_exec($curl);
        //关闭curl
        curl_close($curl);
//     halt($data);
        // json处理
        $jsonObj = json_decode($data, true);
//        dump($jsonObj);
        $result = $jsonObj["result"];
//        dump($result);
        $data1= $result["data"];
//        halt($data1);

        return view('/index/index', [
            'data' => $data,
            'list' => $this->list,
            'res' => $this->res,
            'banner' => $this->banner,
            'style' => $this->style,
            'sort' => $this->sort,
            'data1'=>$data1,


        ]);
    }
}
